package com.ruoyi.safe.service.impl;

import java.util.List;

import cn.hutool.core.util.IdUtil;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.safe.service.IListTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.safe.mapper.ListMaintenanceMapper;
import com.ruoyi.safe.domain.ListMaintenance;
import com.ruoyi.safe.service.IListMaintenanceService;

/**
 * 养护清单Service业务层处理
 * 
 * @author buxi
 * @date 2023-11-06
 */
@Service
public class ListMaintenanceServiceImpl implements IListMaintenanceService 
{
    @Autowired
    private ListMaintenanceMapper listMaintenanceMapper;

    @Autowired
    private IListTypeService listTypeService;

    /**
     * 查询养护清单
     * 
     * @param id 养护清单主键
     * @return 养护清单
     */
    @Override
    public ListMaintenance selectListMaintenanceById(Long id)
    {
        return listMaintenanceMapper.selectListMaintenanceById(id);
    }

    /**
     * 查询养护清单列表
     * 
     * @param listMaintenance 养护清单
     * @return 养护清单
     */
    @Override
    public List<ListMaintenance> selectListMaintenanceList(ListMaintenance listMaintenance)
    {
        return listTypeService.processList(listMaintenanceMapper.selectListMaintenanceList(listMaintenance));
    }
    /**
     * 查询养护清单列表
     *
     * @param listMaintenance 养护清单
     * @return 养护清单
     */
    @Override
    public List<ListMaintenance> selectListMaintenanceListAll(ListMaintenance listMaintenance)
    {
        return listMaintenanceMapper.selectListMaintenanceListAll(listMaintenance);
    }

    /**
     * 新增养护清单
     * 
     * @param listMaintenance 养护清单
     * @return 结果
     */
    @Override
    public int insertListMaintenance(ListMaintenance listMaintenance)
    {
        listMaintenance.setCreateTime(DateUtils.getNowDate());
        listMaintenance.setCreateBy(SecurityUtils.getUsername());
        listMaintenance.setId(IdUtil.getSnowflakeNextId());
        return listMaintenanceMapper.insertListMaintenance(listMaintenance);
    }

    /**
     * 修改养护清单
     * 
     * @param listMaintenance 养护清单
     * @return 结果
     */
    @Override
    public int updateListMaintenance(ListMaintenance listMaintenance)
    {
        listMaintenance.setUpdateTime(DateUtils.getNowDate());
        listMaintenance.setUpdateBy(SecurityUtils.getUsername());
        return listMaintenanceMapper.updateListMaintenance(listMaintenance);
    }

    /**
     * 批量删除养护清单
     * 
     * @param ids 需要删除的养护清单主键
     * @return 结果
     */
    @Override
    public int deleteListMaintenanceByIds(Long[] ids)
    {
        return listMaintenanceMapper.deleteListMaintenanceByIds(ids);
    }

    /**
     * 删除养护清单信息
     * 
     * @param id 养护清单主键
     * @return 结果
     */
    @Override
    public int deleteListMaintenanceById(Long id)
    {
        return listMaintenanceMapper.deleteListMaintenanceById(id);
    }
}
